#!/usr/bin/env node

const log = console.log;

//Part1
let buf1 = Buffer.alloc(256);
buf1[0] = 0;

log('buf1.length:',buf1.length);
log('buf1:',buf1);

//Part2
for(let i = 0;i < buf1.length ; i++){
  buf1[i] = i;
}

//Part3
//后10个到buf2
let buf2 = buf1.slice(246,256);
log('\nbuf2:',buf2);//length

//Par4
//填充为0
buf2.fill(0);
log('\nbuf2:',buf2);
log('\nbuf2\'s JSON:',buf2.toJSON());
log('\nbuf2\'s JSON:',JSON.stringify(buf2));

//Part5
let arr = ['a',0xba,'s','y','x',255];
let buf3 = Buffer.from(arr);
log('\nbuf3:',buf3.length, buf3);

//Part6
let buf4 = Buffer.from('songyaxuan');
log('\nbuf4:',buf4);

//Part7
buf4.copy(buf3,0,0);
log('\nbuf3:',buf3);



console.log('\nhello','world');
